
import java.net.MalformedURLException;
import java.net.URL;

/**
 * Parses an HTTP header for the GET value
 * @author hussein
 */
public class HTTPRequest {

    private URL url;
    
    public HTTPRequest(String input) throws MalformedURLException {
        parseInput(input);
    }

    public URL getUrl() {
        return url;
    }

    private void parseInput(String input) throws MalformedURLException{
        String path = "";
        String lines[] = input.split("\n");
        for (String line : lines) {
            String words[] = line.split(" ");

            if (words[0].equalsIgnoreCase("GET")) {
                path = words[1];
            } 
        }

        url = new URL(path);
    }
}
